#include "MBVec4.h"

#include <cstring>

/**
  * Constructs a new MBVec4 object with coordinates (0 0 0 0)
  */
MBVec4::MBVec4( void )
{
	mValues[0] = 0.0;
	mValues[1] = 0.0;
	mValues[2] = 0.0;
	mValues[3] = 0.0;
}

/**
  * Constructs a new MBVec4 object with the coordinates of the given double array
  *
  * @param values const pointer to the first element of a double array with four elements
  */
MBVec4::MBVec4( const double *values )
{
	memcpy( mValues, values, 4 * sizeof( double ) );
}

/**
  * Constructs a new MBVec4 object with the given coordinates
  *
  * @param v1 element v1
  * @param v2 element v2
  * @param v3 element v3
  * @param v4 element v4
  */
MBVec4::MBVec4( const double &v1, const double &v2, const double &v3, const double &v4 )
{
	mValues[0] = v1;
	mValues[1] = v2;
	mValues[2] = v3;
	mValues[3] = v4;
}

/**
  * Returns a reference to the element at the given index
  *
  * @param index index of the element
  * @return reference to the element at the given index
  */
double &MBVec4::operator[]( const MBuint &index )
{
	return mValues[index];
}

/**
  * Returns a const reference to the element at the given index
  *
  * @param index index of the element
  * @return const reference to the element at the given index
  */
const double &MBVec4::operator[]( const MBuint &index ) const
{
	return mValues[index];
}